/*--------------------------------------------------------------
 * File: demo37.c 编码类型：C语言  UTF-8
 * Author WRS (1352509846@qq.com)
 * 功能: 计算一个数是否可为两个素数之和
 * Version 0.1
 * Date 2022-03-05 
 * 
 * @copyright Copyright (c) 2022
 * 
----------------------------------------------------------------*/
#include <stdio.h>

int checkPrime(int n)
{
    int i = 0;
    int isPrime = 1;
    for(i = 2; i <= n/2; ++i)
    {
        if( n % i == 0)
        {
           isPrime = 0;
           break;
        }
    }

    return isPrime;
}

int main(int argc, char const *argv[])
{
    int n = 0;
    int i = 0;
    int flag = 0;

    printf("输入正整数:");
    scanf("%d",&n);
    
    for(i = 2; i<=n/2; i++)
    {
        if(checkPrime(i) == 1)
        {
            if(checkPrime(n-i) == 1)
            {
                printf("%d = %d * %d\n",n, i, n-i);
                flag = 1;
            }
        }
    }

    if(flag == 0)
        printf("%d 不能被分解为两个素数\n", n );

    return 0;
}



